library(tidyverse)
── Attaching core tidyverse packages ───────────────────────────────────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.2 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.2 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.1 ── Conflicts ─────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(readxl)
library(lubridate)
col_datatypes <- c('numeric','numeric','date','text',rep('numeric',99))
#?read_excel
hourly1 <- read_excel("Hourly Usage 220326 to 220624.xlsx", col_types = col_datatypes)
Warning: Expecting numeric in A277 / R277C1: got 'The information contained in this file is intended for the confidential use by the customer and third parties authorized by the customer to receive the information. Any unauthorized use is prohibited.'
hourly2 <- read_excel("Hourly Usage 220625 to 230623.xlsx", col_types = col_datatypes)
Warning: Expecting numeric in A1096 / R1096C1: got 'The information contained in this file is intended for the confidential use by the customer and third parties authorized by the customer to receive the information. Any unauthorized use is prohibited.'
hourly3 <- read_excel("Hourly Usage 230624 to 231121.xlsx", col_types = col_datatypes)
Warning: Expecting numeric in A457 / R457C1: got 'The information contained in this file is intended for the confidential use by the customer and third parties authorized by the customer to receive the information. Any unauthorized use is prohibited.'
hourly1
hourly2
hourly3
(hourly <- bind_rows(hourly1,list(hourly2,hourly3)))
NA
NA
hourly_pivot <- hourly %>%
pivot_longer(!c("Account Number", "Meter Number", Date, "Read Type", Min, Max, Total), names_to = "Time", values_to = "kWh")
#rm(hourly_pivot)
hourly_pivot <- hourly_pivot %>%
mutate(Time = parse_time(Time, '%H:%M %p'), month = month(Date, label=TRUE), year = year(Date), yday = yday(Date), wday = wday(Date, label=TRUE))
hourly_delivered <- hourly_pivot %>%
filter(`Read Type` == "Delivered Usage kWh")
(hourly_delivered_presolar <- hourly_delivered %>%
filter(Date <= "2022-04-14")
)
NA
ggplot(hourly_delivered_presolar, aes(Time, kWh)) +
geom_point() +
ggtitle("March 26 - April 14, 2022") +
xlab("Energy Delivered (kWh)")
hourly_net_solar <- hourly_pivot %>%
filter(`Read Type` == "kWh Net" & Date > "2022-04-15")
ggplot(hourly_net_solar, aes(Time, kWh)) +
geom_point() +
geom_smooth()
NA
NA
hourly_net_presolar <- hourly_pivot %>%
filter(`Read Type` == "kWh Net" & Date < "2022-04-14")
ggplot(hourly_net_presolar, aes(Time, kWh)) +
geom_point() +
geom_smooth() +
ggtitle("March 26 - April 14, 2022") +
ylab("Energy Delivered (kWh)")
wday_hourly_net_presolar <- hourly_net_presolar %>%
group_by(wday, Time) %>%
summarize(kWhTotal = sum(kWh))
`summarise()` has grouped output by 'wday'. You can override using the `.groups` argument.
ggplot(hourly_net_presolar, aes(Time, kWh, group=wday, color=wday)) +
geom_point() +
geom_smooth() +
ggtitle("March 26 - April 14, 2022")
timeOfDay_presolar <- hourly_net_presolar %>%
group_by(Time) %>%
summarize(kWh_avg = mean(kWh))
ggplot(timeOfDay_presolar, aes(Time, kWh_avg)) +
geom_point() +
ggtitle("March 26 - April 14, 2022") +
ylab("Average Energy Delivered (kWh)")
(hourly_by_date <- hourly_pivot %>%
group_by(Date, `Read Type`) %>%
summarize(kWh = sum(kWh))
)
`summarise()` has grouped output by 'Date'. You can override using the `.groups` argument.
ggplot(hourly_by_date, aes(Date, kWh, group = `Read Type`, color = `Read Type`)) +
geom_point() +
geom_smooth(span = 0.2)
hourly_net_solar <- hourly_pivot %>%
filter(`Read Type` == "kWh Net" & Date > "2022-04-16")
ggplot(hourly_net_solar, aes(Time, kWh)) +
geom_point() +
geom_smooth()
#hourly_net_solar %>% filter(hour(Time) == 2)
timeOfDay_solar <- hourly_net_solar %>%
group_by(Time) %>%
summarize(kWh_avg = mean(kWh), na.rm=TRUE)
ggplot(timeOfDay_solar, aes(Time, kWh_avg)) +
geom_point() +
ggtitle("April 16, 2022 - present") +
ylab("Net Energy Delivered (kWh)")
timeOfDay_month_solar <- hourly_net_solar %>%
group_by(Time, month) %>%
summarize(kWh_avg = mean(kWh))
`summarise()` has grouped output by 'Time'. You can override using the `.groups` argument.
ggplot(timeOfDay_month_solar, aes(Time, kWh_avg, group=month, color=month)) +
geom_point() +
ggtitle("Net Energy Delivered by Time of Day") +
ylab("Net Energy Delivered (kWh)")
hourly <- hourly %>%
#filter(`Read Type` == "kWh Net") %>%
mutate(month = month(Date, label=TRUE), year = year(Date), yday = yday(Date), wday = wday(Date, label=TRUE))
hourly %>%
group_by(`Read Type`, month, year) %>%
summarize(kWh = sum(Total, na.rm = TRUE)) %>%
arrange(year, month)
`summarise()` has grouped output by 'Read Type', 'month'. You can override using the `.groups` argument.
net_by_date <- hourly %>%
group_by(`Read Type`, Date) %>%
summarize(kWh = sum(Total, na.rm = TRUE))
`summarise()` has grouped output by 'Read Type'. You can override using the `.groups` argument.
write.csv(net_by_date, "net_energy_by_date_230701.csv")
hourly %>%
group_by(`Read Type`) %>%
filter(Date > "2022-04-15" & Date <= "2023-04-15") %>%
summarize(kWh = sum(Total, na.rm = TRUE))
NA
I wish I had more of a record before solar! Or a production/consumption monitor!